package com.wfm;

import static com.wfm.constants.Constants.BASE_DIR;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileWriter;
import com.wfm.constants.Constants;
import java.io.BufferedWriter;
import java.io.IOException;
import java.sql.SQLOutput;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MainTest {

    static String data = "wfm";
    static String filename = "test";
    public static void main(String[] args) throws InterruptedException, IOException {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        executorService.execute(()->{
            List<String> strings = FileUtil.listFileNames(Constants.BASE_DIR);
            try {
                System.out.println(Thread.currentThread().getName()+strings);
                FileWriter fileWriter = new FileWriter(BASE_DIR+filename);
                fileWriter.write(data+"exec",true);
                System.out.println(Thread.currentThread().getName()+"s");
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        });
        List<String> strings = FileUtil.listFileNames(Constants.BASE_DIR);
        System.out.println(Thread.currentThread().getName()+strings);
        FileWriter fileWriter = new FileWriter(BASE_DIR+filename);
        fileWriter.write(data+"main",true);
        System.out.println(Thread.currentThread().getName()+"s");
        Thread.sleep(6000);

        executorService.shutdown();
    }
}
